#ifndef __MCS__EXPRESSION__HPP
#define __MCS__EXPRESSION__HPP

#include "Value.hpp"
#include "SourceLocation.hpp"

class Block;

/// Expression that can be evaluated during program execution
class Expression : public Object
{
protected:
	Expression(SourceLocation const & location)
		: Object()
		, location_(location)
		, parentBlock_()
	{}
	virtual ~Expression() {}
public:
	SourceLocation const & location() const { return location_; }
	
	/// Initializes expression object
	virtual void init(Block * parentBlock) { parentBlock_ = parentBlock; }

	/// Evaluates expression
	virtual ptr<Value> evaluate() const = 0;

	/// Returns type of the expression
	/** Type of the expression in undefined until expression object is initialized */
	virtual Value::DataType dataType() const = 0;
protected:
	Block * parentBlock() const { return parentBlock_; }
private:
	Block * parentBlock_;
	SourceLocation location_;
};

#endif //__MCS__EXPRESSION__HPP
